
package sh.wnxy.wn38.controller;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.thymeleaf.util.StringUtils;
import sh.wnxy.wn38.service.IOssService;
import sh.wnxy.wn38.utils.Result;
@ApiModel(value = "文件上传控制器")
@CrossOrigin
@Controller
@RequestMapping("/oss")
public class OssController {

    @Autowired
    private IOssService service;

    @ApiOperation("处理文件上传")
    @ResponseBody
    @RequestMapping("/uploadFile")
    public Result uploadFile(@ApiParam(value = "上传的文件") MultipartFile file){
        String url=service.uploadAvatarFile(file);
        if (StringUtils.isEmpty(url)){
            url="";
        }

    return Result.ok().data("url",url);
    }
}

